<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>物业公告</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="../../css/style.css">
	<script type="text/javascript" src="../../js/jquery-1.8.2.js"></script>
	<script type="text/javascript" src="../../js/dialog/jquery.artDialog.source.js?skin=default"></script>
	<script type="text/javascript" src="../../js/dialog/plugins/iframeTools.source.js"></script>
	<script type="text/javascript" src="../../js/datepicker/WdatePicker.js"></script>
	<script type="text/javascript" src="../../js/jquery.ztree.all-3.5.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.form.js"></script>
	<script type="text/javascript" src="../../js/jquery.page.js"></script>
	<script type="text/javascript" src="../../js/base.js"></script>
	<script type="text/javascript">
	$(function(){
		$('select[name=adminCode]').selectload('../../common/adminunit_select.action','adminCode','adminName');
		//列表
		$('#list').page({
			url:'wygg_search.action',
			config:'pageinfo,record,first,last,next,prev,jump',
			items:[{
				name:'noticeId',
				type:'checkbox'
			},{
				title:'标题',
				name:'noticeTitle'
			},{
				title:'时间',
				name:'noticeDate'
			},{
				title:'状态',
				name:'noticeStatus',
				render:function(row){
					var status;
					switch(row.noticeStatus){
						case '0':
							status = '未审核';
							break;
						case '1':
							status = '未通过审核';
							break;
						case '2':
							status = '通过审核';
							break;
					}
					return status;
				}
			},{
				title:'详情',
				render:function(row){
					$a = $('<a href="javascript:void(0)")">【详细】</a>');
					$a.click(function(){
						view(row);
					});
					return $a;
				}
			}]
		});

		$(document.search).ajaxForm({
			beforeSubmit:function(formData){
				var param = $(formData).formParam();
				$('#list').page('param',param);
				$('#list').page('show');
				return false;
			}
		});

		$('#updForm').ajaxForm({
			success:function(data){
				$('#list').data('checked').length = 0;
				$('#list').page('show');
			}
		});
		$('#btn_upd1,#btn_upd2').click(function(){
			var ids = $('#list').data('checked');
			if(ids.length < 1){
				$.dialog.alert('请选择要审核的公告。');
			}else{
				upd(ids.join(','),$(this).attr('noticeStatus'));
			}
		});
		$('#btn_del').click(function(){
			var ids = $('#list').data('checked');
			if(ids.length < 1){
				$.dialog.alert('请选择要删除的公告信息。');
			}else{
				$.dialog.confirm("您确认要删除所选的公告信息吗？",function(){
					del(ids.join(','));
				});
			}
		});
	});
	var view = function(row){
		$.dialog({
			id:'viewdialog',
			title:'公告详细',
			lock:true,
			width:'100%',
			height:'100%',
			content:document.getElementById('view'),
			button:[{
				name:'通过',
				focus: true,
				callback:function(){
					upd(row.noticeId,2);
					return true;
				}
			},{
				name:'不通过',
				callback:function(){
					upd(row.noticeId,1);
					return true;
				}
			},{
				name:'删除',
				callback:function(){
					$.dialog.confirm("您确认要删除这条新闻信息吗？",function(){
						del(row.noticeId);
					});
					return false;
				}
			}]
		});
		$('#viewForm').json2form(row);
	}
	var upd = function(ids,noticeStatus){
		$.post('wygg_save.action',{ids:ids,noticeStatus:noticeStatus},function(data){
			$('#list').data('checked').length = 0;
			$('#list').page('show');
		});
	}
	var del = function(ids){
		$.post('wygg_del.action',{ids:ids},function(data){
			if($.dialog.list['viewdialog'] != undefined){
				$.dialog.list['viewdialog'].close();
			}
			$('#list').data('checked').length = 0;
			$('#list').page('show');
		},'json');
	}
	</script>
</head>
<body class="app">
	<h3>物业公告</h3>
	<form class="search" name="search">
		<div class="tbdiv">
		<table>
			<tr>
				<th>关键字：</th>
				<td colspan="4">
					<input type="text" class="inputText" name="kw" style="width:392px;"/>
					<select  name="kwtype">
						<option value="1">标题</option>
						<option value="2">内容</option>
					</select>
				</td>
			</tr>
			<tr>
				<th>行政监管单位：</th>
				<td><select name="adminCode"></select></td>
				<th>状态：</th>
				<td colspan="2">
					<select>
						<option name="unit" value="">请选择</option>
						<option name="unit" value="0">未审核</option>
						<option name="unit" value="1">未通过审核</option>
						<option name="unit" value="2">通过审核</option>
					</select>
				</td>
			</tr>
			<tr>
				<th>起始时间：</th>
				<td><input type="text" id="st" class="inputText" name="startDate" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'et\')}'})" style="width:110px;"/></td>
				<th>截止时间：</th>
				<td><input type="text" id="et" class="inputText" name="endDate" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'st\')}'})" style="width:110px;"/></td>
				<td><input type="submit" value="查询" class="inputButton"/></td>
			</tr>
		</table>
		</div>
	</form>
	<div id="list"></div>
	<div class="optionlink">
		<span id="btn_upd1" noticeStatus="2">【通过】</span>
		<span id="btn_upd2" noticeStatus="1">【不通过】</span>
		<span id="btn_del">【删除所选】</span>
	</div>
	<div class="areaTree"><div id="areaTree" class="ztree"></div></div>
	<div id="view" style="width:350px;display:none;">
		<form name="viewForm" id="viewForm">
		<dl class="view">
			<dt>公告标题：</dt>
			<dd class="giant"><label name="noticeTitle"></label></dd>
			<dt style="height:52px;">内容：</dt>
			<dd class="giant" style="height:52px;"><textarea name="noticeContent" class="inputText" style="width:253px;height:42px;" readonly="readonly"></textarea></dd>
			<div class="cl"></div>
		</dl>
		</form>
	</div>
</body>
</html>
